<div class="contextual">
  <%= permalink_to_timesheet(@timesheet) %>
</div>

<h2><%= l(:timesheet_title)%></h2>

<%= render :partial => 'form' %>

<% form_tag({}, { :id => 'time_entries'}) do -%>
<% if @timesheet.time_entries.length > 0 %>
<h2><%= l(:label_spent_time) %> (<%= h(number_with_precision(@grand_total, @precision)) -%> <%= h(l(:field_hours)) -%>)</h2>

<% @timesheet.time_entries.each do |entryname,entry|
    case @timesheet.sort
    when :user %>
   <h3><%= h entryname -%> (<%= h number_with_precision(@total[entryname], @precision) %> <%= h(l(:field_hours)) -%>)</h3>
   <%= render :partial => 'timesheet_group', :locals => {:entry => entry, :name => entryname, :total => @total[entryname] } %>
<% when :issue %>
   <h3><%= h entryname -%> (<%= h number_with_precision(@total[entryname], @precision) %> <%= h(l(:field_hours)) -%>)</h3>
   <%= render :partial => 'by_issue', :locals => {:entry => entry, :name => entryname, :total => 0 } %>
<% else # Default to :project %>
   <h3><%= h entryname -%> (<%= h number_with_precision(@total[entryname], @precision) %> <%= h(l(:field_hours)) -%>) <%= showing_users(entry[:users]) %></h3> 
   <%= render :partial => 'timesheet_group', :locals => {:entry => entry, :name => entryname, :total => @total[entryname] } %>

<% end
end # each
end # length
end # form_tag
-%>

<% content_for(:header_tags) do %>
<%= javascript_include_tag 'context_menu' %>
<%= stylesheet_link_tag 'context_menu' %>
<style type="text/css">

div#timesheet-form p { padding:0px 10px; float:left; }

</style>
<%= call_hook(:plugin_timesheet_view_timesheets_report_header_tags, { :timesheet => @timesheet }) %>
<% end %>

<div id="context-menu" style="display: none;"></div>
<%= javascript_tag "new ContextMenu('#{url_for(:controller => 'timesheet', :action => 'context_menu')}')" %>

<%= call_hook(:plugin_timesheet_view_timesheets_report_bottom, { :timesheet => @timesheet }) %>
